package com.jt.tenant.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.jt.tenant.R;
import com.jt.tenant.app.JTApplication;
import com.zcx.helper.pager.CarouselChild;

/**
 * Created by Administrator on 2016/2/14.
 */
public class HomeBannerView extends CarouselChild<String>{

    public HomeBannerView(Context context, AttributeSet attrs) {

        super(context, attrs);

    }

    @Override
    protected boolean isPlay() {

        return true;

    }

    @Override
    protected View getView(String s) {

        ImageView imageView = new ImageView(getContext());

        imageView.setScaleType(ImageView.ScaleType.FIT_XY);

        imageView.setBackgroundResource(R.mipmap.loading);

//        imageView.setImageResource(s);

        JTApplication.UtilAsyncBitmap.get(s, imageView);

        return imageView;

    }

    @Override
    protected View indicatorLayout(LinearLayout indicatorLayout) {

        int size = JTApplication.ScaleScreenHelper.getWidthHeight(12);

        indicatorLayout.setGravity(Gravity.BOTTOM|Gravity.CENTER_HORIZONTAL);

        indicatorLayout.setPadding(0, size, 0, size);

        return indicatorLayout;

    }

    @Override
    protected View indicator(View indicator) {

        int size = JTApplication.ScaleScreenHelper.getWidthHeight(10);

        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(size, size);

        layoutParams.leftMargin = layoutParams.rightMargin = size / 2;

        indicator.setLayoutParams(layoutParams);

        return indicator;

    }


    @Override
    protected int indicatorOn() {

        return R.mipmap.home_indicator_on;

    }

    @Override
    protected int indicatorOff() {

        return R.mipmap.home_indicator_off;

    }

}
